<template>
	<section>
		<!--工具条-->
		<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
			<el-form :inline="true" :model="filters">
				<el-form-item>
					<el-input v-model="filters.keyword" placeholder="姓名"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" v-on:click="getUsers">查询</el-button>
				</el-form-item>
				<!--<el-form-item>
					<el-button type="primary" @click="handleAdd">新增</el-button>
				</el-form-item>-->
			</el-form>
		</el-col>

		<!--列表-->
		<template>
			<el-table :data="users" highlight-current-row v-loading="listLoading" style="width: 100%;">
				<el-table-column type="index" width="60">
				</el-table-column>
				<el-table-column prop="username" label="姓名" width="120" sortable>
				</el-table-column>
				<el-table-column prop="email" label="邮箱" width="100" :formatter="formatSex" sortable>
				</el-table-column>
				<el-table-column prop="age" label="年龄" width="100" sortable>
				</el-table-column>
				<el-table-column prop="phone" label="电话" width="120" sortable>
				</el-table-column>
				<el-table-column prop="password" label="密码" min-width="180" sortable>
				</el-table-column>
				<el-table-column prop="shop_id" label="店铺码" min-width="180" sortable>
				</el-table-column>
			</el-table>
			<!--工具条
			<el-col :span="24" class="toolbar">
				<el-button type="danger" @click="batchRemove" :disabled="this.sels.length===0">批量删除</el-button>
				<el-pagination layout="prev, pager, next"
							   @current-change="handleCurrentChange"
							   :page-size="pageSize"
							   :total="total"
							   style="float:right;">
				</el-pagination>
			</el-col>-->
		</template>

	</section>
</template>
<script>
	import { getUserList } from '../../api/api';
	//import NProgress from 'nprogress'
	export default {
		data() {
			return {
				filters: {
					keyword: ''
				},
				loading: false,
				users: [],
				total:0
			}
		},
		methods: {
			/*//性别显示转换
			formatSex: function (row, column) {
				return row.sex == 1 ? '男' : row.sex == 0 ? '女' : '未知';
			},*/
			//获取用户列表
			/*getUser: function () {
				let para = {
					name: this.filters.name
				};
				this.loading = true;
				//NProgress.start();
				getUserList(para).then((res) => {
					this.users = res.data.users;
					this.loading = false;
					//NProgress.done();
				});
			}*/
			handleCurrentChange(val) {
				this.currentPage = val;
				this.getUsers();
			},
			getUsers() {
				let para = {
					currentPage: this.currentPage,
					pageSize: this.pageSize,
					keyword: this.filters.keyword
				};
				this.listLoading = true;

				// 自己发送请求
				this.$http.post("/employee",para)
						.then(result=>{
							this.users = result.data.rows;
							this.total = result.data.totals;
							this.listLoading = false;
						}).catch(result=>{
					//console.debug(result)
					alert("垃圾系统")
				})

			},
		},

		mounted() {
			this.getUsers();
		}
	};

</script>

<style scoped>

</style>